home *** CD-ROM | disk | FTP | other *** search
- ;;;; "test.scm", routines for testing.
- ;Copyright (C) 1991 Aubrey Jaffer
- ;
- ;Permission to copy this software, to redistribute it, and to use it
- ;for any purpose is granted, subject to the following restrictions and
- ;understandings.
- ;
- ;1. Any copy made of this software must include this copyright notice
- ;in full.
- ;
- ;2. I have made no warrantee or representation that the operation of
- ;this software will be error-free, and I am under no obligation to
- ;provide any services, by way of maintenance, update, or otherwise.
- ;
- ;3. In conjunction with products arising from the use of this
- ;material, there shall be no use of my name in any advertising,
- ;promotional, or sales literature without prior written consent in
- ;each case.
-
- (define cur-section '())
-
- (define errs '())
-
- (define SECTION (lambda args
- (display "SECTION") (write args) (newline)
- (set! cur-section args) #t))
-
- (define record-error
- (lambda (e) (set! errs (cons (list cur-section e) errs))))
-
- (define test
- (lambda (expect fun . args)
- (write (cons fun args))
- (display " ==> ")
- ((lambda (res)
- (write res)
- (newline)
- (cond ((not (equal? expect res))
- (record-error (list res expect (cons fun args)))
- (display " BUT EXPECTED ")
- (write expect)
- (newline)
- #f)
- (else #t)))
- (if (procedure? fun) (apply fun args) (car args)))))
-
- (define (report-errs)
- (newline)
- (if (null? errs) (display "Passed all tests")
- (begin
- (display "errors were:")
- (newline)
- (display "(SECTION (got expected (call)))")
- (newline)
- (for-each (lambda (l) (write l) (newline))
- errs)))
- (newline))
-